package org.example;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class UserDao {
	//UserDao不要写update2那种测试代码
    List<User> userList = null;
    Map<Integer,String> map = null;
    public UserDao(){
        userList = new ArrayList<>();
        map = new HashMap<>();
    }

    public List<User> getAll(){
        return new ArrayList<>(userList);
    }

    public boolean delete(User user){
        userList.remove(user);
        return true;
    }
    public boolean add(User user){
        userList.add(user);
        return true;
    }
    public boolean update(int i,User user){
        userList.set(i-1,user);
        return true;
    }
    public  boolean update1(int id,String name){
        map.put(id,name);
        return true;
    }
    public  boolean update2(){
      map.put(1,"速八");
      return true;
    }
}
